package service.impl.v2;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import dao.v2.ApplyReturnVOMapper;
import dao.v2.MemberVOMapper;
import dao.v2.OrderEvaluateVOMapper;
import dao.v2.OrderVOMapper;
import model.FileVO;
import model.OrderBackVO;
import model.OrderEvaluateVO;
import model.OrderGoodVO;
import model.OrderVO;
import model.SeqVO;
import service.v2.OrderEvaluateService;
@Service
public class OrderEvaluateServiceImpl implements OrderEvaluateService {
	@Autowired
	private OrderVOMapper orderVOMapper;
	@Autowired
	private OrderEvaluateVOMapper dao;
	@Autowired
	private ApplyReturnVOMapper applyReturnVOMapper;
	
	
	public void evaluSub(String member_id,String order_id,String standard_id, String text, String imgs) {
		// TODO Auto-generated method stub
		//存 file
		String folder_id = "";
		if(imgs!=null&&imgs!=""){
			SeqVO seq = new SeqVO();
			applyReturnVOMapper.getSeq(seq);
			folder_id = seq.getSeq();
			String[] filePah = imgs.split(",");
			for (int i = 0; i < filePah.length; i++) {
				FileVO fileVO = new FileVO();
				//评价图
				fileVO.setCat_id("195");
				fileVO.setPath(filePah[i]);
				fileVO.setFolder_id(folder_id);
				applyReturnVOMapper.addFile(fileVO);
				applyReturnVOMapper.addFileFolder(folder_id,fileVO.getId());
			}
		}
		
		OrderGoodVO ordergood = new OrderGoodVO();
		ordergood.setOrder_id(order_id);
		ordergood.setGood_standard_id(standard_id);
		ordergood.setMember_id(member_id);
		ordergood.setEvaluate(text);
		ordergood.setEvaluate_time("");
		if(folder_id!=""){
			ordergood.setFold_id(folder_id);
		}
		dao.updOrderGoodEvaluate(ordergood);
		dao.updOrderEvaluate(order_id);
		//update  evaluate
		
	}


	public List<OrderGoodVO> getOrderGoodByOrderId(String order_id,String standard_id) {
		// TODO Auto-generated method stub
		return dao.getOrderGoodByOrderId(order_id,standard_id);
	}


	public List<OrderEvaluateVO> getEvalueByGoodId(OrderEvaluateVO evaluateVO) {
		// TODO Auto-generated method stub
		return dao.getEvalueByGoodId(evaluateVO);
	}


	public List<OrderGoodVO> getCustomServiceList(String member_id) {
		// TODO Auto-generated method stub
		return dao.getCustomServiceList(member_id);
	}


	public List<OrderBackVO> getOrderBackByMemberId(String member_id,String order_id,String country) {
		// TODO Auto-generated method stub
		return dao.getOrderBackByMemberId(member_id,order_id,country);
	}


	public int getTotal(OrderEvaluateVO evaluateVO) {
		// TODO Auto-generated method stub
		return dao.getTotal(evaluateVO);
	}


	public int getEvaluateToTalRecord(String good_id) {
		// TODO Auto-generated method stub
		return dao.getEvaluateToTalRecord(good_id);
	}

}
